Add TAL-Reverb-II plugin to test
[juce-lv2.git] / juce / source / extras / the jucer / src / model / jucer_JucerDocument.h
blobeab821ec8fb60751efd27ece6564f8adc12e4d34
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCER_JUCERDOCUMENT_JUCEHEADER__
27 #define __JUCER_JUCERDOCUMENT_JUCEHEADER__
29 #include "components/jucer_ComponentTypeHandler.h"
30 #include "jucer_PaintRoutine.h"
31 #include "jucer_ComponentLayout.h"
32 #include "jucer_BinaryResources.h"
35 //==============================================================================
36 /**
37 This is the main document base class, which loads, saves and manages the state of
38 an entire jucer component.
40 It contains a ComponentLayout object to represent its sub-components, and
41 one or more PaintRoutine objects to represent sets of drawing operations it
42 might want to do.
44 It also holds a BinaryResources object to manage its resources.
46 class JucerDocument : public FileBasedDocument,
47 private Timer
49 public:
50 //==============================================================================
51 JucerDocument();
52 ~JucerDocument();
54 void changed();
56 virtual JucerDocument* createCopy() = 0;
57 virtual const String getTypeName() const = 0;
59 //==============================================================================
60 UndoManager& getUndoManager() throw() { return undoManager; }
62 bool perform (UndoableAction* const action, const String& actionName);
64 void refreshAllPropertyComps();
66 //==============================================================================
67 const String& getClassName() const throw() { return className; }
68 void setClassName (const String& newName);
70 const String& getComponentName() const throw() { return componentName; }
71 void setComponentName (const String& newName);
73 const String getParentClassString() const;
74 void setParentClasses (const String& classes);
76 const String getConstructorParams() const;
77 void setConstructorParams (const String& newParams);
79 const String getVariableInitialisers() const;
80 void setVariableInitialisers (const String& newInitlialisers);
82 void setFixedSize (const bool isFixed);
83 bool isFixedSize() const throw() { return fixedSize; }
85 void setInitialSize (int w, int h);
87 int getInitialWidth() const throw() { return initialWidth; }
88 int getInitialHeight() const throw() { return initialHeight; }
90 //==============================================================================
91 virtual int getNumPaintRoutines() const = 0;
92 virtual const StringArray getPaintRoutineNames() const = 0;
93 virtual PaintRoutine* getPaintRoutine (const int index) const = 0;
95 virtual ComponentLayout* getComponentLayout() const = 0;
97 virtual Component* createTestComponent (const bool alwaysFillBackground) = 0;
99 virtual void addExtraClassProperties (PropertyPanel* panel);
101 //==============================================================================
102 virtual void getOptionalMethods (StringArray& baseClasses,
103 StringArray& returnValues,
104 StringArray& methods,
105 StringArray& initialContents) const;
107 void setOptionalMethodEnabled (const String& methodSigniture, const bool enable);
108 bool isOptionalMethodEnabled (const String& methodSigniture) const throw();
110 //==============================================================================
111 BinaryResources& getResources() throw() { return resources; }
113 //==============================================================================
114 void setSnappingGrid (const int numPixels, const bool active, const bool shown);
116 int getSnappingGridSize() const throw() { return snapGridPixels; }
117 bool isSnapActive (const bool disableIfCtrlKeyDown) const throw();
118 bool isSnapShown() const throw() { return snapShown; }
120 int snapPosition (int pos) const throw();
122 //==============================================================================
123 void setComponentOverlayOpacity (const float alpha);
124 float getComponentOverlayOpacity() const throw() { return componentOverlayOpacity; }
126 //==============================================================================
127 static const char* const jucerCompXmlTag;
129 /** Creates the document's metadata xml section.
131 This doesn't include resources, which are done separately.
133 virtual XmlElement* createXml() const;
135 /** Restores the sub-components and graphics from xml metadata.
137 This doesn't include resources, which aren't altered.
139 virtual bool loadFromXml (const XmlElement& xml);
141 static XmlElement* pullMetaDataFromCppFile (const String& cpp);
143 //==============================================================================
144 // Code generation
146 /** Fills in a GeneratedCode structure with this component's state. */
147 virtual void fillInGeneratedCode (GeneratedCode& code) const;
149 virtual void fillInPaintCode (GeneratedCode& code) const;
151 /** Tries to track down and load the header and cpp templates.
153 bool findTemplateFiles (String& templateH, String& templateCpp) const;
155 /** Generates and returns the header and cpp file contents for this component. */
156 void getPreviewFiles (String& header, String& cpp);
159 protected:
160 const String getDocumentTitle();
161 const String loadDocument (const File& file);
162 const String saveDocument (const File& file);
163 const File getLastDocumentOpened();
164 void setLastDocumentOpened (const File& file);
167 protected:
168 //==============================================================================
169 String className;
170 String componentName;
171 String parentClasses, constructorParams, variableInitialisers;
172 bool fixedSize;
173 int initialWidth, initialHeight;
175 BinaryResources resources;
177 static void addMethod (const String& base, const String& returnVal, const String& method, const String& initialContent,
178 StringArray& baseClasses, StringArray& returnValues, StringArray& methods, StringArray& initialContents);
180 private:
181 UndoManager undoManager;
182 int snapGridPixels;
183 bool snapActive, snapShown;
184 Component* lastFocusedComp;
185 int lastClickCounter;
186 float componentOverlayOpacity;
188 StringArray activeExtraMethods;
190 void timerCallback();
192 //==============================================================================
193 const String getMetadata() const;
195 bool writeCodeFiles (const File& headerFile,
196 const File& cppFile,
197 String headerTemplate,
198 String cppTemplate) const;
202 #endif // __JUCER_JUCERDOCUMENT_JUCEHEADER__